# !pip install diffusers
import torch
from diffusers import DiffusionPipeline
import PIL.Image

model_id = "/home/gxnu/.cache/huggingface/hub/models--fusing--glide-base"
# model_id = "fusing/glide-base"

# load model and scheduler
pipeline = DiffusionPipeline.from_pretrained(model_id)

# run inference (text-conditioned denoising + upscaling)
img = pipeline("a crayon drawing of a corgi")

# process image to PIL
img = img.squeeze(0)
img = ((img + 1)*127.5).round().clamp(0, 255).to(torch.uint8).cpu().numpy()
image_pil = PIL.Image.fromarray(img)

# save image
image_pil.save("./test.png")
